'use client';
import Container from '@/components/Container';
import FilterPanel from '@/components/FilterPanel';
import { CUISINES } from '@/lib/data';
import { useAppStore } from '@/store';
import { useRouter } from 'next/navigation';
import type { Cuisine } from '@/lib/types';

export default function FilterPage() {
  const router = useRouter();
  const { selectedCuisines, addCuisine, clearCuisines } = useAppStore();

  const handleSubmit = (excluded: Cuisine[]) => {
    clearCuisines();
    excluded.forEach((cuisine) => addCuisine(cuisine));
    router.push('/result?mode=exclude');
  };

  return (
    <Container>
      <h1 className="text-xl font-semibold mb-3">反向筛选</h1>
      <FilterPanel
        allCuisines={CUISINES}
        initialExcluded={selectedCuisines}
        onSubmit={handleSubmit}
      />
    </Container>
  );
}
